<!--Generate by Kevin's CodeBuilder -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
		<meta charset="UTF-8">
	<title>工作流管理系统</title>
	<head  th:replace="source::header"></head>
</head>
<body>
<div id="form_container" class="form_container">

			<table class="k_form_table">
					<tr>
						<td class="label label100">XLS中的根机构代码(多个根请用英文;分隔)</td>
						<td >
							<textarea id="rootCode" rows="3" style="width: 340px;height:80px;"></textarea>
						</td>
					</tr>

					<tr>
						<td class="label label100">[(${Lang.common_selectFile})]</td>
						<td >
							<div id="fileUpload3"></div>
						</td>
					</tr>
					<tr>
						<td colspan="2" style="padding-left:150px;padding-top:30px;position: relative">
							<button class="k_icon_fff" id="submit_btn">
								<i class="fa fa-arrow-circle-up"></i>
								[(${Lang.common_btn_uploadData})]
							</button>
							<a id="model_load" href="/upload/tmpls/机构数据_模板.xls"  target='k_down_load_ifr' download=""  style="position: absolute;right: 10px;top:6px; text-decoration: underline;cursor: pointer;">下载填写模板</a>
						</td>
					</tr>
				</table>	
				<p id="message" style="text-align:center;line-height:22px;color:red;"></p>

	</div>
	<script type="text/javascript"  th:inline="javascript">
			$B.DomUtils.onDomLoaded(function(){
				  var $root = document.getElementById("rootCode");
				  var $msg = document.getElementById("message");
				  var pid = '[(${pid})]';
				  $B.DomUtils.focus($root,()=>{
					  $msg.innerText = "";
				  });
		          var upload3 =  new $B.Upload("fileUpload3",{
					  timeout: 600, //超时时间 秒
					  url: $B.getHttpHost()+"org/import",
					  multiple: false, //是否可批量选择
					  fileParamName: 'attachments',
					  immediate: false, //选择文件后是否立即自动上传，即不用用户点击提交按钮就上传
					  accept: '.xls,.xlsx',   // 可上传的文件类型 .xml,.xls,.xlsx,.png
					  onSelected: function(file,fileName){ //选择文件后的事件请返回true 以便通过验证
						  console.log(fileName);
						  return true;
					  },
					  success: function(mesage, data, res){ //成功时候的回调
						  console.log("success "+mesage);
						  parent.closeWindow(pid);
					  },
					  onDeleted: function(res){//删除回调,function(res){ }
						  console.log("delete "+res);
					  },
					  setParams: function(){ //设置参数 return {}
					  	 let rootCode = $root.value;
					  	 let prs = {"rootCode":rootCode,pid:pid};
					  	 console.log("setparmas ",prs);
						 return prs;
					  }
				  });
		          $B.DomUtils.click(document.getElementById("submit_btn"),function () {
					  let rootCode = document.getElementById("rootCode").value;
					  if(rootCode !== ""){
						  upload3.upload();
					  }else{
						  $msg.innerText = "根机构代码不能为空！";
					  }
				  });
			});
	
	</script>
</body>
</html>